home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / animutil / kfast / kfast.lzh / KFAST / src / render2.c < prev    next >
C/C++ Source or Header  |  1992-07-03  |  3KB  |  149 lines

  1. #include <proto/intuition.h>
  2. #include <proto/graphics.h>
  3. #include <intuition/intuition.h>
  4. #include <exec/memory.h>
  5. #include "skeleton.h"
  6.  
  7. int dispmode = ALL;
  8.  
  9. static struct Border border={ 0, 0, 1, 0, JAM1, -1, NULL, NULL};
  10.  
  11. void DrawFrame(obj_ptr frame)
  12. {
  13.     obj_ptr object;
  14.     
  15.     if(frame==NULL) return;
  16.  
  17.     object = frame->framedown;
  18.     while(object!=NULL)
  19.     {
  20.         if(((dispmode&IMAGE)!=0) ||
  21.           ((dispmode==ENTRY) && ((object->entry&IMAGE)!=0)))
  22.         DrawObject(object->image,object->offset[0],object->offset[1]);
  23.         object = object->framedown;
  24.     }
  25.  
  26.     object = frame->framedown;
  27.     while(object!=NULL)
  28.     {
  29.         if(((dispmode&SKELETON)!=0) ||
  30.           ((dispmode==ENTRY) && ((object->entry&SKELETON)!=0)))
  31.         DrawObject(object->skeleton,object->offset[0],object->offset[1]);
  32.         object = object->framedown;
  33.     }
  34.     object = frame->framedown;
  35.     while(object!=NULL)
  36.     {
  37.         if(((dispmode&XOUTLINE)!=0) ||
  38.           ((dispmode==ENTRY) && ((object->entry&XOUTLINE)!=0)))
  39.         DrawOutline(object->outline,object->skeleton,object->offset[0],object->offset[1]);
  40.         object = object->framedown;
  41.     }
  42. }
  43.  
  44. void FillObject(line_ptr line,int xoff, int yoff)
  45. {
  46.     SHORT *newbuff;
  47.     int i;
  48.  
  49.     SetAPen(RP,line->fillc);
  50.     
  51.     if((xoff+line->box[0][0]<0)   || (yoff+line->box[0][1]<0) ||
  52.        (xoff+line->box[1][0]>ScrnWidth) || (yoff+line->box[1][1]>ScrnHeight))
  53.            return;    /* put in clipping later */
  54.     if(line->number>=AreaSize)
  55.     {
  56.         /* Added 1 incase AreaEnd adds a point */
  57.         i = line->number + 1 + MEM_BLOCKSIZE - ((line->number+1)%MEM_BLOCKSIZE);
  58.         newbuff = (SHORT *)malloc(5*i);
  59.           if(newbuff==NULL)
  60.             return;
  61.         free(AreaBuffer,5*AreaSize);
  62.         AreaSize = i;
  63.         AreaBuffer = newbuff;
  64.         InitArea(RP->AreaInfo,AreaBuffer,AreaSize);
  65.     }
  66.     
  67.     if(line->number<3)
  68.         return;
  69.             
  70.     AreaMove(RP,line->pts->p[0][0],line->pts->p[0][1]);
  71.     for(i=1;i<line->number;i++)
  72.     {
  73.         AreaDraw(RP,line->pts->p[i][0],line->pts->p[i][1]);
  74.     }
  75.     AreaEnd(RP);
  76.         
  77. }
  78.  
  79. void DrawObject(line_ptr line,int xoff, int yoff)
  80. {
  81.     int i;
  82.     
  83.     while(line!=NULL)
  84.     {
  85.        if(line->fillc!=0) FillObject(line,xoff,yoff);
  86.        border.FrontPen = line->linec;
  87.        i  = 0;
  88.        while(line->number>i)
  89.        {
  90.         border.XY = (SHORT *)line->pts->p[i];
  91.  
  92.         if(line->number-i<=101)
  93.         {
  94.             border.Count = line->number-i;
  95.             i = line->number;
  96.         }
  97.         else
  98.         {
  99.             border.Count = 101;
  100.             i = i + 100;
  101.         }
  102.         
  103.         if(border.Count==1)
  104.             border.Count = 2;
  105.         if(border.Count>1)
  106.         {
  107.             DrawBorder(RP,&border,xoff,yoff);
  108.         }
  109.        }
  110.         line = line->next;
  111.     }
  112. }
  113.  
  114. void DrawOutline(line_ptr out,line_ptr skel,int xoff, int yoff)
  115. {
  116.     int i;
  117.     SHORT points[3][2];
  118.     
  119.     if(out==NULL) return;
  120.  
  121.     border.FrontPen = out->linec;    
  122.     border.Count = 3;
  123.     border.XY = points[0];
  124.     
  125.     for(i=0;i<out->number;i++)
  126.     {
  127.     points[0][0]=points[1][0]=points[2][0] = out->pts->p[i][0];
  128.     points[0][1]=points[1][1]=points[2][1] = out->pts->p[i][1];
  129.     
  130.     if((skel!=NULL) && (i/2<skel->number))
  131.     {
  132.         points[0][0] = skel->pts->p[i/2][0];
  133.         points[0][1] = skel->pts->p[i/2][1];
  134.     }
  135.     if(i<out->number-2)
  136.     {
  137.         points[2][0] = out->pts->p[i+2][0];
  138.         points[2][1] = out->pts->p[i+2][1];        
  139.     }
  140.     DrawBorder(RP,&border,xoff,yoff);
  141.     }
  142. }
  143.  
  144. void EraseFrame(obj_ptr frame)
  145. {
  146.     SetRast(RP,0);
  147. }
  148.  
  149.